package com.thero.core.net;

import io.netty.channel.Channel;

/**
 * Created by wusk on 2017/12/8.
 * 连接信息，主要用于维持心跳
 */
public class ClientChannel {
    private Channel channel;
    private long time;
    private int times;
    private boolean send;

    public ClientChannel(Channel c){
        this.channel = c;
        this.time = System.currentTimeMillis();
        this.times = 0;
        this.send = false;
    }

    public Channel getChannel(){
        return this.channel;
    }

    public void send(ProtocolMessage[] messages){
        channel.writeAndFlush(messages);
        this.time = System.currentTimeMillis();
    }

    public void sendHeartbeat(ProtocolMessage message){
        channel.writeAndFlush(message);
        this.time = System.currentTimeMillis();
        this.send = true;
    }
}
